package com.jt.service;

import com.jt.mapper.UserMapper;
import com.jt.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("target")
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;
    public void addUser(User user) {
        //ctrl+alt+t 快速生成try catch
        try {
            System.out.println("事务开始");
            userMapper.addUser(user);
            System.out.println("事务结束");
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("事务回滚");
        }
    }
}
